<h2>Post News </h2>
<hr>
<form action="javascript:submit();" autocomplete="off" class="uniForm" style="padding:0.5em 1em 1em 1.5em;">
		<fieldset id="basicID" >
		<div class="ctrlHolder">
          <label for="news_title"><em>*</em>News title:</label>
          <input name="news_title" id="news_title" size="35" maxlength="30" type="text" class="textInput required validatePhrase"/>
          <p class="formHint">Not more than 30 characters.</p>
        </div>
        
        <div class="ctrlHolder">
          <label for="news_summary"><em>*</em>One line summary:</label>
          <input name="news_summary" id="news_summary" size="35" maxlength="60" type="text" class="textInput required validatePhrase"/>
          <p class="formHint">Not more than 60 characters.</p>
        </div>
        
        <div class="ctrlHolder"><label for="news_body"><em>*</em>Body</label> <textarea
			name="news_body" id="news_body" 
			rows="25" cols="25"></textarea>
		<p class="formHint">Complete information about the news. Not more than 2000 words.</p>
		</div>
		<div class="buttonHolder">
        <button type="reset" class="secondaryAction">Clear form</button>
        <button type="submit" class="primaryAction">Submit</button>
      </div>
      
 <div id="submitStatus" style="display:none;" class="ui-state-highlight ui-corner-all" ></div>
		</fieldset>
</form>		
<script>
	var urlPostNews = "<?php echo $this->url(array('module'=>'admin', 'controller' => 'news', 'action' => 'imod'))?>";

	function submit() {
        $.ajax({
            url : urlPostNews,
            data : getValues(),
            success: function(jStatus){
                $( "#submitStatus" ).text(jStatus).toggle( 'blind', '', 'slow', function(){  
                	setTimeout(function(){
//                    	 window.location.reload();
                    	},1400);
                } );
            },
                error: function(response) {
              	  $('#errorBox').text(response.responseText).parent().show();
                    console.log(response);
                    }
                });
    }

    function getValues() {
        var formData = {oper:'add'}; 
        $('form.uniForm :input')
        		.not('button,:input[value^="e.g."]')
        		.each(function(){ 
        			formData[this.name] = this.value; 
            });
        return formData;
    }
</script>
<?php
$baseUrl = $this->baseUrl();
$this->headScript()->appendFile($baseUrl.'/plugins/uni-form/js/uni-form-validation.jquery.js');
$this->headLink()->prependStylesheet($baseUrl.'/plugins/uni-form/css/uni-form.css');
$this->headLink()->prependStylesheet($baseUrl.'/plugins/uni-form/css/smooth.uni-form.css');
$this->headLink()->prependStylesheet($baseUrl.'/plugins/uni-form/demos/css/demo.css');
?>